package com.example.algorithm.LinkedListAlgorithm;

/**
 * @author ZMJ
 * @date 2020/3/23
 */
public class LinkedHaveRingTest {

    public static void main(String args[]) {
        Node head = new Node("1", "1");
        Node node2 = new Node("2", "2");
        Node tail = new Node("3", "3");

        head.setNext(node2);
        node2.setNext(tail);
        tail.setNext(null);

//        boolean isHaveRing = LinkedHaveRingBySet.isHaveRing(head);
        boolean isHaveRing = LinkedHaveRingByFastSlow.isHaveRing(head);
        System.out.println("是否又环:" + isHaveRing); // false

        tail.setNext(node2); // 制造环
//        boolean isHaveRing = LinkedHaveRingBySet.isHaveRing(head);
        isHaveRing = LinkedHaveRingByFastSlow.isHaveRing(head);
        System.out.println("是否又环:" + isHaveRing); // true
    }



}
